<?php
namespace app\traits;

trait JsonResponse{
    public function jsonSuccess($data=[],$message='操作成功',$httpCode=200,$myCode=1){
        return json([
            'code'=>$myCode,
            'message'=>$message,
            'status'=>'success',
            'data'=>$data
        ])->code($httpCode);
    }

    public function jsonFail($data=[],$message='操作失败',$httpCode=403,$myCode=0){
        return json([
            'code'=>$myCode,
            'message'=>$message,
            'status'=>'fail',
            'data'=>$data
        ])->code($httpCode);
    }
}